home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
PRINTER.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-03-01
|
26KB
|
515 lines
TITLE Printer
PAGE 66,132
;* * * * * * * * * * * * * * P R I N T E R * * * * * * * * * * * * * * *
;
; John C. Petrey
; (c) 1983
;
;
;
;
CSEG segment para public 'CODE'
org 100h
;
;
PRINTER proc far
assume cs:cseg,ds:cseg,es:nothing
;
jmp set_up
;
;Data Area
;
disk db 00h ;current default disk drive
bytes_left db 00h ;bytes of code left to read
sav_row db 02h ;start cursor at line 2
kbd_input db ' ' ;save keyboard input
print_lit db 'N' ;flag to indicate if we were printing literal
option_nbr db '0' ;option number printed on the screen
fcb db 00h ;1st byte of FCB (00h = default drive)
fcb2 db 'printer ' ;file name in FCB
fcb3 db 'dat' ;file extension in FCB
fcb4 db 25 dup(00h) ;remainder of FCB
dta db 128 dup('d') ;disk transfer area
eof db '$' ;end of disk transfer area
codes db 20 dup('c') ;user codes
line1 db 'Printer (1.1) - Special Print Functions$'
more db 'Change another setting? $'
nomatch db 'Please choose an option listed above $'
quest db 'Your Choice $'
option db 'Option $'
done db ' done!$'
escape db 'Esc - Exit$'
dash db ' - $'
no_file db 'PRINTER.DAT file not found or error in file$'
;
;Setup stuff
set_up:
push ds ;Set return segment address and ...
sub ax,ax ;put zero on stack ...
push ax ;so a RET returns us to starting address.
push cs ;Move work address into Data Segment ...
pop ds ;because this is a COM file.
;
;Save registers ;By saving register contents at program
push ax ;entry we insure exit will correctly
push bx ;return to DOS.
push cx
push dx
sti ;enable interrupts
;
;Set screen mode
mov al,2 ;80 x 25 B&W alpha
mov ah,0 ;BIOS interrupt 10 - set video mode
int 10h ;call BIOS to do it
;
;Clear screen
mov ah,6 ;clear screen with scroll active page up
mov al,0 ;entire window
mov cx,0 ;ch,cl = row,column of upper left corner
mov dh,24 ;dh = row to scroll to
mov dl,79 ;dl = column to scroll to
mov bh,7 ;attribute to be used on blank line
int 10h ;Call BIOS to scroll
;
;Title
mov dx,offset line1 ;get address of program title
call print ;print it on the screen
;
;Save current default disk drive
mov ah,19h ;DOS function to get default drive
int 21h ;Call DOS to do it - returned in AL
mov disk,al ;Save default disk returned in AL
;
;Get drive on which PRINTER.DAT file is located
mov si,80h ;point to command tail address
mov dh,[si] ;get length of command tail
tail:
cmp dh,00h ;Is their a command tail? or any bytes of tail left?
je set_dta ; no, go set DTA
dec dh ; yes, update bytes of tail left
inc si ; point to next byte in command tail
mov dl,[si] ; get contents of command tail
cmp dl,097 ;Is drive spec upper case?
jb upper ; yes, now go fold to a value
sub dl,32 ; no, fold down to upper case
upper:
sub dl,65 ;fold to a value
;
;Select disk drive
cmp dl,5 ;if value not valid (a - f) ...
ja tail ; get next command tail byte
cmp dl,0 ;if value not valid ...
jb tail ; get next command tail byte
mov ah,0Eh ;DOS function to select disk
int 21h ;call DOS to do it
;
;Set Disk Transfer Address
set_dta:
mov dx,offset dta ;get address of Disk Transfer Area (DTA)
mov ah,1Ah ;DOS function to set Disk Transfer Area (DTA)
int 21h ;call DOS to set DTA
;Open File Control Block
mov dx,offset fcb ;point to address of File Control Block (FCB)
mov ah,0fh ;DOS function to open file control block
int 21h ;call DOS to open file control block
mov bp,00h ;initialize base pointer - used later
;as offset into user codes
;
;Sequential read
read:
mov dx,offset fcb ;get address of file control block
mov ah,14h ;DOS function to read a record
int 21h ;call DOS to do it. AL returns 00 if successful.
cmp al,00h ;Was read successful?
je success ; Yes, continue with program
cmp al,03 ;Was partial record read?
je success ; Yes, continue with program
file_not_found:
mov dx,offset no_file ; No, get address of error message
call cursor ; print error message
jmp exit ; exit
success:
;
mov SI,00h ;initialize SI to zero - will use SI as offset
;within DTA (byte were currently working with)
;
cmp dta[si],'&' ;Is this the end of the users file?
jne not_end ; No, still more to read
jmp cont ; Yes, we're done reading users file
not_end: ;
;
cmp bytes_left,0 ;Were we reading codes when we reached end of DTA?
je not_reading ; No
jmp read_code ; Yes, go finsih reading codes
not_reading:
;
cmp dta[si],'$' ;Did we just finish printing a literal when we
;reached the end of the DTA?
je end_of_literal ; Yes, now read codes
;
cmp print_lit,'Y' ;Were we printing the literal when we reached the end of the DTA?
je finish_print ; Yes,